import ajax from '@/utils/ajax'
let _this_;
const getData = () => _this_.curData || _this_.curData;
const getLoading = () => _this_.loading || _this_.loading;
let rolesCheck = (rule, value, callback) => {
    _this_.$ajax.get(_this_.$api.system.role.check,{code:getData().code,id:getData().id}).then(result => {
        if(result.bean>0) {
            callback("角色编码已存在");
        } else {
            callback();
        }
    }).catch(error => {
        callback("获取角色编码异常");
    });
}
export default function (context) {
    _this_ = context;
    return {
        code: [
            {required: true, message: '请输入编码', trigger: 'blur'},
            {min: 3, max: 15, message: '长度在 3 到 15 个字符', trigger: 'blur'},
            {pattern: /^[a-zA-Z0-9]+$/, message: '编码格式不正确', trigger: 'blur'},
            {validator: rolesCheck, trigger: 'blur'},
        ],
        name: [
            {required: true, message: '请输入名称', trigger: 'blur'},
            {min: 3, max: 25, message: '长度在 3 到 20 个字符', trigger: 'blur'},
        ],
        type: [
            {required: true, message: '请选择用户类型', trigger: 'blur'}
        ],
        enabled: [
            {required: true, message: '请选择状态', trigger: 'blur'}
        ],
    }
}
